/**
 * Created by zdx on 2016/8/26 0026.
 */
define(["jquery","bootstrap","slimscroll","fastclick","app","controller","rights","additionalmethods","moment"],function ($) {
    var  c= require("controller");
    var  moment= require("moment");
    $.validator.addMethod("twoDate", function(value, element, param) {
        if($(param[0]).val()!=""&&$(param[1]).val()!=""){
            var st=moment($(param[0]).val()).format('X');
            var ed=moment($(param[1]).val()).format('X');
            return st< ed;
        }{
            return true
        }
    }, $.validator.format("开始日期必须小于结束日期"));

    $.validator.addMethod("isAscii", function(value, element, param) {
        var aaa=/^[a-zA-Z0-9_-]*$/.test(value)///[[:ascii:]]/
       return this.optional(element) || aaa;
    }, $.validator.format("包含非法字符"));


    c.ajax({
        url:'t',
        success:function (result) {
            c.serveDate=result
        }
    });

    return {
        init:function () {
            var c=require("controller");
            var rights=require("rights");
            rights.islogin();
            rights.isShowFn('.main-sidebar');
            $('title,.logo-lg').text(c.getTitle());
            $('.main-sidebar .sidebar-menu').on("click","a[data-url]",function (e) {
                rights.islogin();
                c.conLog(c.plInterval);

                window.clearInterval(c.plInterval);
                c.urlLoad({url:$(this).attr('data-url')});
                return false;
            });
            $('#menu_user').on('click',function (e) {
                if(confirm('确定要退出系统吗?')){
                    c.quit();
                }
            });
            $('#menu_user>span').text('退出('+c.getValues('name')+')');

            if(c.getValues('rights').indexOf('1000')!=-1){
                c.urlLoad({url:'moniter/index.html'});
            }else{
                $('.sidebar-menu li[data-rights]').each(function () {
                    var right=$(this).attr('data-rights');

                    if(c.getValues('rights').indexOf(right)!=-1){
                        c.conLog($(this).find('a').attr('data-url'))
                        c.urlLoad({url:$(this).find('a').attr('data-url')});
                        return false;
                    }
                })
            }
        }
    }
});



